package com.iring.dao.common;

import org.springframework.data.jpa.repository.query.Procedure;
import org.springframework.data.repository.CrudRepository;

import com.iring.domain.common.ProxyInfo;


/**
 * @author wanggan
 */
public interface ProxyDao extends CrudRepository<ProxyInfo, Integer> {

    ProxyInfo findByMacAndUsernameAndSendStatusIsTrue(String mac, String username);

    ProxyInfo findByMacAndUsername(String mac, String username);

    ProxyInfo findByMac(String mac);
    ProxyInfo findByMacAndSendStatusIsTrue(String mac);

    ProxyInfo findDistinctByProxyUsername(String proxyUsername);

    /**
     * 更新设备状态
     *
     * @param mac
     *          MAC地址
     * @param username
     *          用户名
     * @return  执行结果,成功<code>1</code>
     * 失败<code>0</code>
     */
    @Procedure(procedureName = "USP_DEVICE_DOMAIN_UPDATE_PROC")
    Integer updateDeviceDomain(String mac, String username);
}
